.responsive-table {
  min-width: 50rem;

  @media (max-width: 768px) {
    min-width: 100% !important;
    width: 100% !important;
  }
}

.directory-picker {
  width: 650px;
  max-width: 650px;
  display: flex;
  flex-direction: column;

  @media (max-width: 640px) {
    width: 100%;
    max-width: 100%;
  }
}

.panel-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem 1.5rem 1.25rem 1.5rem;
  border-radius: 10px 10px 0 0;
  border: 1px solid var(--border-color);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);

  .header-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: var(--primary-color);
    border-radius: 10px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);

    .header-icon {
      font-size: 1.5rem;
      color: var(--primary-contrast-color);
    }
  }

  .header-text {
    flex: 1;

    .panel-title {
      margin: 0 0 0.25rem 0;
      font-size: 1.25rem;
      font-weight: 600;
      color: var(--text-color);
    }

    .panel-description {
      margin: 0;
      font-size: 0.875rem;
      color: var(--text-secondary-color);
    }
  }

  @media (max-width: 480px) {
    padding: 1rem;

    .header-icon-wrapper {
      width: 40px;
      height: 40px;

      .header-icon {
        font-size: 1.25rem;
      }
    }

    .header-text {
      .panel-title {
        font-size: 1.125rem;
      }

      .panel-description {
        font-size: 0.8rem;
      }
    }
  }
}

.picker-controls {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem 2rem;
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-top: none;

  .current-path {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem;
    background: var(--overlay-background);
    border-radius: 6px;

    .path-label {
      display: flex;
      align-items: center;
      gap: 0.375rem;
      color: var(--text-secondary-color);
      font-weight: 600;
      font-size: 0.9rem;
      white-space: nowrap;

      i {
        color: coral;
      }
    }

    .path-value {
      flex: 1;
      color: var(--text-color);
      font-family: monospace;
      font-size: 0.875rem;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }

  .controls-row {
    display: flex;
    gap: 0.75rem;

    .search-input-wrapper {
      position: relative;
      flex: 1;

      ::ng-deep {
        .p-inputicon {
          color: var(--text-secondary-color);
        }
      }

      .clear-icon {
        position: absolute;
        right: 1rem;
        top: 50%;
        transform: translateY(-50%);
        color: var(--text-secondary-color);
        cursor: pointer;
        transition: color 0.2s;
        z-index: 1;

        &:hover {
          color: var(--text-color);
        }
      }
    }
  }

  .selection-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;
    background: var(--primary-color);
    color: var(--primary-contrast-color);
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.875rem;

    i {
      font-size: 0.875rem;
    }
  }

  @media (max-width: 480px) {
    padding: 1rem;
    gap: 0.5rem;

    .current-path {
      flex-direction: column;
      align-items: flex-start;
      gap: 0.5rem;

      .path-value {
        width: 100%;
      }
    }

    .controls-row {
      flex-direction: column;
      gap: 0.5rem;
    }
  }
}

.directories-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem 2rem;
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-top: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  min-height: 350px;
  max-height: 450px;
  overflow: hidden;

  @media (max-width: 480px) {
    padding: 1rem;
    min-height: 300px;
    max-height: 400px;
  }
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--text-secondary-color);

  ::ng-deep .custom-spinner {
    .p-progress-spinner-circle {
      stroke: var(--primary-color);
    }
  }
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem 1rem;
  flex: 1;

  .empty-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    background: var(--overlay-background);
    border-radius: 50%;
    margin-bottom: 1rem;

    .empty-icon {
      font-size: 2.5rem;
      color: var(--text-secondary-color);
      opacity: 0.5;
    }
  }

  .empty-title {
    margin: 0 0 0.5rem 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-color);
  }

  .empty-description {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-secondary-color);
    max-width: 350px;
    line-height: 1.5;
  }

  @media (max-width: 480px) {
    padding: 1.5rem 0.75rem;

    .empty-icon-wrapper {
      width: 60px;
      height: 60px;

      .empty-icon {
        font-size: 2rem;
      }
    }

    .empty-title {
      font-size: 1rem;
    }

    .empty-description {
      font-size: 0.8rem;
      max-width: 100%;
    }
  }
}

.directories-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  height: 100%;
  overflow: hidden;
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 0.875rem;
  background: var(--overlay-background);
  border-radius: 6px;

  .folder-count {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-color);

    i {
      color: var(--primary-color);
    }
  }

  @media (max-width: 480px) {
    padding: 0.5rem 0.625rem;

    .folder-count {
      font-size: 0.85rem;
    }
  }
}

.directories-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
  flex: 1;
  padding-right: 0.25rem;
  min-height: 0;

  &::-webkit-scrollbar {
    width: 6px;
  }

  &::-webkit-scrollbar-track {
    background: var(--overlay-background);
    border-radius: 3px;
  }

  &::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
    transition: background 0.2s ease;

    &:hover {
      background: var(--primary-color);
    }
  }

  scrollbar-width: thin;
  scrollbar-color: var(--border-color) var(--overlay-background);
}

.directory-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--ground-background);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  transition: all 0.3s ease;
  cursor: pointer;

  &:hover {
    border-color: var(--primary-color);
    transform: translateX(3px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);

    .directory-icon {
      color: var(--primary-color);
      transform: scale(1.08);
    }

    .navigate-icon {
      opacity: 1;
      transform: translateX(2px);
    }
  }

  &.selected {
    border-color: var(--p-primary-800);

    .directory-icon-wrapper {
      background: var(--primary-color);

      .directory-icon {
        color: var(--primary-contrast-color);
      }
    }
  }

  .directory-checkbox {
    display: flex;
    align-items: center;
  }

  .directory-label {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    min-width: 0;

    .directory-icon-wrapper {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 38px;
      height: 38px;
      background: var(--overlay-background);
      border-radius: 8px;
      flex-shrink: 0;

      .directory-icon {
        font-size: 1.125rem;
        color: var(--text-secondary-color);
        transition: all 0.3s ease;
      }
    }

    .directory-info {
      flex: 1;
      display: flex;
      flex-direction: column;
      gap: 0.25rem;
      min-width: 0;

      .directory-name {
        font-size: 0.9375rem;
        color: var(--text-color);
        font-weight: 500;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      .directory-path {
        font-size: 0.75rem;
        color: var(--text-secondary-color);
        font-family: monospace;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
    }

    .navigate-icon {
      color: var(--text-secondary-color);
      opacity: 0;
      transition: all 0.3s ease;
      flex-shrink: 0;
    }
  }

  @media (max-width: 480px) {
    padding: 0.625rem;
    gap: 0.5rem;

    .directory-label {
      gap: 0.5rem;

      .directory-icon-wrapper {
        width: 32px;
        height: 32px;

        .directory-icon {
          font-size: 1rem;
        }
      }

      .directory-info {
        .directory-name {
          font-size: 0.875rem;
        }

        .directory-path {
          display: none;
        }
      }
    }
  }
}

.dialog-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);

  .footer-info {
    flex: 1;

    .selection-info {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      color: var(--text-secondary-color);
      font-size: 0.9rem;

      i {
        color: var(--primary-color);
      }
    }
  }

  .footer-actions {
    display: flex;
    gap: 0.75rem;
  }

  @media (max-width: 480px) {
    flex-direction: column;
    padding: 1rem;
    gap: 0.5rem;

    .footer-info {
      width: 100%;
      text-align: center;
    }

    .footer-actions {
      width: 100%;
      justify-content: flex-end;
      gap: 0.5rem;
    }
  }
}

@media (max-width: 768px) {
  .directory-picker {
    border-radius: 0;
  }

  .picker-header,
  .search-bar,
  .current-path,
  .directory-list,
  .picker-footer {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .folder-item {
    .folder-info {
      .folder-path {
        display: none;
      }
    }
  }

  .current-path {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;

    .path-value {
      width: 100%;
    }

    .selected-count {
      align-self: flex-start;
    }
  }

  .picker-footer {
    flex-direction: column;
    align-items: stretch;

    .footer-info {
      text-align: center;
    }

    .footer-actions {
      width: 100%;

      button {
        flex: 1;
      }
    }
  }
}
